package com.wistech.search.solr.function.analyzer;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringReader;

import net.paoding.analysis.analyzer.PaodingAnalyzer;

import org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer;
import org.apache.lucene.util.Version;
import org.junit.BeforeClass;
import org.wltea.analyzer.core.IKSegmenter;

import com.chenlb.mmseg4j.analysis.ComplexAnalyzer;

public class BaseBench {
	protected static String benchText;
	static {
		new IKSegmenter(new StringReader("自来水"), true);
		new ComplexAnalyzer();
		new SmartChineseAnalyzer(Version.LUCENE_31);
		new PaodingAnalyzer();
	}

	@BeforeClass
	public static void init() {
		StringBuffer sb = new StringBuffer();
		String testFile = "test.txt";
		BufferedReader reader = null;
		try {
			reader = new BufferedReader(new InputStreamReader(
					BaseBench.class.getResourceAsStream(testFile)));
			String text = reader.readLine();
			while (text != null) {
				sb.append(text).append("\n");
				text = reader.readLine();
			}
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			if (reader != null) {
				try {
					reader.close();
				} catch (IOException e) {
				}
			}
		}
		benchText = sb.toString();
	}
}
